<template lang="pug">
  .table-wrapper
    //- DataTableMain.table-fixed.table-left(
    //-   v-if="$attrs.operationList.length"
    //-   v-bind="$attrs"
    //-   v-on="$listeners"
    //-   :x="0"
    //-   :tableList="[]"
    //-   :hoverRecord="hoverRecord"
    //-   :tableWrapperWidth="$attrs.operationWidth"
    //-   @changeHoverRecord="changeHoverRecord")
    DataTableMain.table-main(
      ref="table-main"
      v-bind="$attrs"
      v-on="$listeners"
      tableName="table-main"
      :isScroll="true"
      :hasLoading="true"
      :hoverRecord="hoverRecord"
      :y="y"
      :x="x"
      @updatePosition="updatePosition"
      @updateY="updateY"
      @changeHoverRecord="changeHoverRecord")
    DataTableMain.table-fixed.table-right(
      v-if="$attrs.operationList.length"
      v-bind="$attrs"
      v-on="$listeners"
      :tableList="[]"
      :hoverRecord="hoverRecord"
      :tableWrapperWidth="$attrs.operationWidth"
      :y="y"
      :x="0"
      @updatePosition="updatePosition"
      @updateY="updateY"
      @changeHoverRecord="changeHoverRecord")
</template>

<script>
/**
 * @name DataTable 组件
 * @author 陈可嘉 <chenkj@gddxit.com>
 * @description 通过配置资源列表URL、资源列定义直接出表格
 */
import DataTableMain from './Main'

export default {
  name: 'data-table-body',
  components: {
    DataTableMain
  },
  data () {
    return {
      x: 0,
      y: 0,
      hoverRecord: null,
      treeExpands: []
    }
  },
  computed: {
    countData () {
      return this.tableData
    }
  },
  methods: {
    changeHoverRecord (index) {
      this.hoverRecord = index
    },
    updatePosition (x, y) {
      this.x = x
      this.y = y
    },
    updateY (y) {
      this.y = y
    }
  }
}
</script>

<style scoped lang="sass">
.table-wrapper
  border: 1px solid #ddd
  position: relative
  overflow: hidden
.table-main
  height: 100%
.table-fixed
  position: absolute
  z-index: 1
  overflow: hidden
  top: 0
  height: 100%
  box-shadow: 0 0 5px #888
.table-right
  right: 0
  border-left:  1px solid #ddd
// .table-left
//   left: 0
//   border-right:  1px solid #ddd
</style>
